package ar.edu.ufasta.presupuestos.servicios.web.netpacks;

import java.util.StringTokenizer;

import ar.edu.ufasta.presupuestos.servicios.web.Constantes;

public class TransaccionPresupuestoResponse extends ResponsePack {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3657996557784723266L;

	@Override
	public void codificarTrama() {
		trama = "";
		trama = trama + protocol + ";";
		trama = trama + systemCode + ";";
		trama = trama + resultCode + ";";
		int checksum = trama.length()+1;
		trama = trama + Integer.toString(checksum) + ";";
		trama = trama + "\n";	
	}

	@Override
	public void decodificarTrama() {
		StringTokenizer st = new StringTokenizer(trama,";");
		st.countTokens();
		try {
			protocol = Integer.valueOf(st.nextToken());
			systemCode = Integer.valueOf(st.nextToken());
			resultCode = Integer.valueOf(st.nextToken());
		} catch (Exception e) {
			protocol = Constantes.PROTOCOL_100;
			systemCode = Constantes.SYSTEM_CODE;
			resultCode = Constantes.ERROR_OPERATIONCODE;
		}	
	}

}
